all: sphere

PATCH_NAME = sphere
PATCH_SRCS_DIR = src/baseVector.c src/sphere.c src/3Dmain.c 
PATCH_OBJS_DIR = $(patsubst src/%.c,objects/%.o,$(wildcard src/*.c))
PATCH_OBJS = $(patsubst src/%.c,%.o,$(wildcard src/*.c))
VPATH=src/:include/:objects/:bin/:lib/:SOIL_include/:SOIL_src/
PATCH_INCLUDE=$(wildcard include/*.h)

PATCH_LIB = libSOIL.so
PATCH_INCLUDE_LIB=$(wildcard SOIL_include/*.h)
PATCH_SRC_LIB=$(wildcard SOIL_src/*.c)

CC = gcc

CCINCPATH = -I/usr/X11R6/include
LDFLAGS = -L/usr/X11R6/lib -L/usr/lib -Llib -lGLU -lglut -lGL -lm -lSOIL
CFLAGS = -Wall -Iinclude/ -ISOIL_include/ -g


sphere:$(PATCH_OBJS) $(PATCH_LIB)
	$(CC) -o $(PATCH_NAME) $(PATCH_OBJS_DIR) $(CFLAGS) $(LDFLAGS)
	mv sphere bin/

%.o: %.c
	$(CC) $(CCINCPATH) $(CCOPTS) $(CFLAGS)  -c -o $@ $<
	mv $@ objects/

# tout nos objets dépendent de l'ensemble des includes
# (en vrai non mais ça raccourci le makefile)
$(PATCH_OBJS): $(PATCH_INCLUDE)

$(PATCH_LIB) : $(PATCH_SRC_LIB)
	$(CC) --shared -fpic -o $(PATCH_LIB) $(PATCH_SRC_LIB)  $(CFLAGS) 
	mv $(PATCH_LIB) lib/

clean:
	rm -f $(CURVE_OBJS) $(PATCH_OBJS_DIR) $(CURVE_NAME) bin/$(PATCH_NAME) 

test: $(PATCH_NAME)
	export LD_LIBRARY_PATH=$LD_LIBRARY_PATH+':lib/' && ./bin/sphere
